home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / HYP / C-D / DragRect.cpt / DragRect / card_2825.txt < prev    next >
Text File  |  1989-02-26  |  11KB  |  387 lines

  1. -- card: 2825 from stack: in
  2. -- bmap block id: 3489
  3. -- flags: 0000
  4. -- background id: 2596
  5. -- name: 
  6.  
  7.  
  8. -- part 9 (button)
  9. -- low flags: 00
  10. -- high flags: 2004
  11. -- rect: left=165 top=124 right=166 bottom=210
  12. -- title width / last selected line: 0
  13. -- icon id / first selected line: 20098 / 20098
  14. -- text alignment: 1
  15. -- font id: 0
  16. -- text size: 12
  17. -- style flags: 0
  18. -- line height: 16
  19. -- part name: Home
  20. ----- HyperTalk script -----
  21. on mouseUp
  22.   visual effect barn door close to black
  23.   visual effect barn door open to inverse
  24.   go home
  25. end mouseUp
  26.  
  27.  
  28.  
  29. -- part 8 (button)
  30. -- low flags: 00
  31. -- high flags: 2004
  32. -- rect: left=208 top=124 right=166 bottom=253
  33. -- title width / last selected line: 0
  34. -- icon id / first selected line: 13785 / 13785
  35. -- text alignment: 1
  36. -- font id: 0
  37. -- text size: 12
  38. -- style flags: 0
  39. -- line height: 16
  40. -- part name: Install
  41. ----- HyperTalk script -----
  42. on mouseUp
  43.   if the optionkey is down then pass mouseup
  44.   put installres(XFCN,DragRect) into it
  45.   if it is empty then play boing
  46.   else answer it
  47. end mouseUp
  48.  
  49. --
  50. --this function is used by the 'install' button
  51. --It then attempts to install the resource into
  52. --a target stack & returns the result.
  53. --
  54. function installres type, resname
  55. --
  56. --Original script by Steve Drazga, ART Incorpoated
  57. --XFCNs used: fileName,
  58. --XCMDs used: modResCopy,
  59. --HANDLERS used: none
  60. --FUNCTIONS used: none
  61. --
  62. put (long name of this stack) into sourceStack
  63. delete first word of sourceStack
  64. delete first character of sourceStack
  65. delete last character of sourceStack
  66. put "Select a stack to copy this resource into."
  67. put filename("STAK") into fname
  68. if fname is empty then exit installres
  69. if sourcestack=fname then
  70.   play "Boing"
  71.   return "Get real.  You can't install it in this stack"
  72.   exit installres
  73. end if
  74. hide the message window
  75. --
  76. ModResCopy sourceStack,fname,type,resname
  77. --
  78. get the result
  79. if first char of it is "E" then
  80.   play "Boing"
  81.   return "Attempt to install resource has failed."
  82. else
  83.   return "Resource installation successful"
  84. end if
  85. end installres
  86.  
  87.  
  88.  
  89.  
  90. -- part 10 (button)
  91. -- low flags: 00
  92. -- high flags: 2004
  93. -- rect: left=251 top=124 right=166 bottom=296
  94. -- title width / last selected line: 0
  95. -- icon id / first selected line: 6347 / 6347
  96. -- text alignment: 1
  97. -- font id: 0
  98. -- text size: 12
  99. -- style flags: 0
  100. -- line height: 16
  101. -- part name: Show Code
  102. ----- HyperTalk script -----
  103. on mouseUp
  104.   show card field code
  105.   show card button "Hide Code"
  106.   show card button "Hide Code 1"
  107. end mouseUp
  108.  
  109.  
  110.  
  111. -- part 3 (field)
  112. -- low flags: 80
  113. -- high flags: 0004
  114. -- rect: left=118 top=69 right=272 bottom=364
  115. -- title width / last selected line: 0
  116. -- icon id / first selected line: 0 / 0
  117. -- text alignment: 0
  118. -- font id: 3
  119. -- text size: 12
  120. -- style flags: 0
  121. -- line height: 16
  122. -- part name: DragRectangle
  123.  
  124.  
  125. -- part 1 (button)
  126. -- low flags: 80
  127. -- high flags: 8002
  128. -- rect: left=118 top=69 right=92 bottom=362
  129. -- title width / last selected line: 0
  130. -- icon id / first selected line: 0 / 0
  131. -- text alignment: 1
  132. -- font id: 0
  133. -- text size: 12
  134. -- style flags: 0
  135. -- line height: 16
  136. -- part name: _____ Please Drag Me _____
  137. ----- HyperTalk script -----
  138. --
  139. -- Draggable window simulation, ¬©1988 by Richard P. Davis.  Use it
  140. -- as you please with this notice intact.  If you make improvements,
  141. -- please distribute them on the networks.
  142. --
  143. on mouseDown
  144.   put the loc of card button id 1 into oldloc  -- remember the locations
  145.   put the loc of card field id 3 into backloc  -- of the elements of the
  146.   put the loc of card field id 4 into textloc  -- window so we can change
  147.   put the loc of card button id 6 into awayloc -- change them all at the
  148.   if the optionkey is down then                -- same time.
  149.     put 1 into constraint                      -- if the option key or
  150.   else if the commandkey is down then          -- the command key are
  151.     put 2 into constraint                      -- held down, constrain
  152.   else                                         -- the movement of the
  153.     put 0 into constraint                      -- drag to horizonal or
  154.   end if                                       -- vertical only.
  155.   --
  156.   -- Use the XFCN to drag the rectangle of our window around, starting
  157.   -- from the ClickLoc.  The XFCN returns the offset from the clickloc
  158.   -- as its result if all goes well, or "False" if an error occurs.
  159.   --
  160.   put DragRect(the clickloc, the rect of card field id 3, constraint) into newLoc
  161.   --
  162.   -- Now we need to move all of the parts of our window, the background
  163.   -- field we use to get the rect from, the button we use as the title
  164.   -- bar, the scrolling field we use as the content region, and the
  165.   -- button we use for a go away box.  Use lockscreen to make them look
  166.   -- as if the all move at once.
  167.   --
  168.   if newLoc is not "False" then
  169.     set lockscreen to true
  170.     add item 1 of newLoc to item 1 of oldLoc
  171.     add item 2 of newLoc to item 2 of oldLoc
  172.     set the loc of me to oldLoc
  173.     add item 1 of newLoc to item 1 of backloc
  174.     add item 2 of newLoc to item 2 of backloc
  175.     set the loc of card field id 3 to backLoc
  176.     add item 1 of newLoc to item 1 of textloc
  177.     add item 2 of newLoc to item 2 of textloc
  178.     set the loc of card field id 4 to textLoc
  179.     add item 1 of newloc to item 1 of awayloc
  180.     add item 2 of newloc to item 2 of awayloc
  181.     set the loc of card button id 6 to awayLoc
  182.     set lockscreen to false
  183.   else
  184.     play "Boing"      -- If there was a problem doing the drag, play
  185.   end if              -- Boing at the customer...
  186. end mouseDown
  187.  
  188.  
  189.  
  190. -- part 6 (button)
  191. -- low flags: 80
  192. -- high flags: 0000
  193. -- rect: left=125 top=75 right=87 bottom=137
  194. -- title width / last selected line: 0
  195. -- icon id / first selected line: 14184 / 14184
  196. -- text alignment: 1
  197. -- font id: 0
  198. -- text size: 12
  199. -- style flags: 0
  200. -- line height: 16
  201. -- part name: Go Away
  202. ----- HyperTalk script -----
  203. --
  204. -- Draggable window simulation, ¬©1988 by Richard P. Davis.  Use it
  205. -- as you please with this notice intact.  If you make improvements,
  206. -- please distribute them on the networks.
  207. --
  208. on mouseUp
  209.   set lockscreen to true
  210.   put the mouseloc into mloc
  211.   put item 1 of the rect of me into left     -- decompose the rect of
  212.   put item 2 of the rect of me into top      -- the button for easier
  213.   put item 3 of the rect of me into right    -- comparison purposes.
  214.   put item 4 of the rect of me into bottom
  215.   --
  216.   -- If the mouse was released within the goawaybox, hide all of the
  217.   -- window elements.  That is why we have the lockscreen on, so the
  218.   -- whole window appears to go away at once.
  219.   --
  220.   if item 1 of mloc > left and item 1 of mloc < right and item 2 of mloc > top and item 2 of mloc < bottom then
  221.     hide card button id 1
  222.     hide card button id 6
  223.     hide card field id 3
  224.     hide card field id 4
  225.     show card button id 2
  226.   end if
  227.   set lockscreen to false
  228. end mouseUp
  229. --
  230. -- This handler used in place of TrackGoAway to keep hiliting and
  231. -- unhiliting the GoAwayBox until the user makes up their mind.
  232. --
  233. on mouseDown
  234.   set the icon of me to 26211                -- hilited version of icon
  235.   put item 1 of the rect of me into left     -- decompose the rect of
  236.   put item 2 of the rect of me into top      -- the button for easier
  237.   put item 3 of the rect of me into right    -- comparison purposes.
  238.   put item 4 of the rect of me into bottom
  239.   --
  240.   -- The following loop will track the mouse movement until the user
  241.   -- releases the mouse button. When the mouse is within the GoAwayBox
  242.   -- the GoAwayIcon will be the Hilited version, but whenever the mouse
  243.   -- leaves the box, that icon will be replaced by its nonhilited
  244.   -- cousin.
  245.   --
  246.   repeat while the mouse is down
  247.     if the mouseh < left or the mouseh > right or the mousev < top or the mousev > bottom then
  248.       set the icon of me to 14184
  249.     else
  250.       set the icon of me to 26211
  251.     end if
  252.   end repeat
  253.   set the icon of me to 14184  -- End up with the unhilited version.
  254. end mouseDown
  255.  
  256.  
  257.  
  258.  
  259.  
  260. -- part 4 (field)
  261. -- low flags: 81
  262. -- high flags: 2007
  263. -- rect: left=118 top=91 right=270 bottom=362
  264. -- title width / last selected line: 0
  265. -- icon id / first selected line: 0 / 0
  266. -- text alignment: 0
  267. -- font id: 3
  268. -- text size: 12
  269. -- style flags: 768
  270. -- line height: 16
  271. -- part name: TextRectangle
  272.  
  273.  
  274. -- part 13 (button)
  275. -- low flags: 80
  276. -- high flags: 2000
  277. -- rect: left=251 top=124 right=165 bottom=295
  278. -- title width / last selected line: 0
  279. -- icon id / first selected line: 0 / 0
  280. -- text alignment: 1
  281. -- font id: 0
  282. -- text size: 12
  283. -- style flags: 0
  284. -- line height: 16
  285. -- part name: Hide Code 1
  286. ----- HyperTalk script -----
  287. on mouseUp
  288.   set lockscreen to true
  289.   hide card field "Code"
  290.   hide card button "Hide Code"
  291.   hide card button "Hide Code 1"
  292.   set lockscreen to false
  293. end mouseUp
  294.  
  295.  
  296.  
  297. -- part 2 (button)
  298. -- low flags: 00
  299. -- high flags: A004
  300. -- rect: left=165 top=164 right=202 bottom=296
  301. -- title width / last selected line: 0
  302. -- icon id / first selected line: 0 / 0
  303. -- text alignment: 1
  304. -- font id: 0
  305. -- text size: 12
  306. -- style flags: 0
  307. -- line height: 16
  308. -- part name: Push for demo
  309. ----- HyperTalk script -----
  310. on mouseUp
  311.   set lockscreen to true
  312.   hide card field code
  313.   hide card button "Hide Code"
  314.   hide card button "Hide Code 1"
  315.   show card button id 1
  316.   show card button id 6
  317.   show card field id 3
  318.   show card field id 4
  319.   set scroll of card field id 4 to 0
  320.   hide card button id 2
  321.   set lockscreen to false
  322. end mouseUp
  323.  
  324.  
  325.  
  326. -- part 11 (field)
  327. -- low flags: 80
  328. -- high flags: 2004
  329. -- rect: left=135 top=71 right=289 bottom=343
  330. -- title width / last selected line: 0
  331. -- icon id / first selected line: 0 / 0
  332. -- text alignment: 0
  333. -- font id: 3
  334. -- text size: 12
  335. -- style flags: 0
  336. -- line height: 16
  337. -- part name: code
  338.  
  339.  
  340. -- part 12 (button)
  341. -- low flags: 80
  342. -- high flags: 0000
  343. -- rect: left=134 top=71 right=289 bottom=342
  344. -- title width / last selected line: 0
  345. -- icon id / first selected line: 0 / 0
  346. -- text alignment: 1
  347. -- font id: 0
  348. -- text size: 12
  349. -- style flags: 0
  350. -- line height: 16
  351. -- part name: Hide Code
  352. ----- HyperTalk script -----
  353. on mouseUp
  354.   set lockscreen to true
  355.   hide card field "Code"
  356.   hide card button "Hide Code"
  357.   hide card button "Hide Code 1"
  358.   set lockscreen to false
  359. end mouseUp
  360.  
  361.  
  362.  
  363. -- part contents for card part 4
  364. ----- text -----
  365. This draggable window was easily created using the DragRect XFCN.  Look at the  card button called ‚ÄúPlease Drag Me‚Äù to see how it was done.
  366.  
  367. Try dragging the window as you would any standard Macintosh window.  Also try dragging the window with the option key held down, or with the command key held down.
  368.  
  369. The DragRect XFCN is free of charge for noncommercial use only.  If you would like to license it (with C source) for use in a commercial or shareware product, please call or write to:
  370.  
  371.     Richard P. Davis 
  372.     260 Sheridan St. #100 
  373.     Palo Alto, Ca. 94306
  374.     (415) 324-9333 
  375.  
  376.   ¬©1988 Richard P. Davis
  377.  
  378.  
  379. -- part contents for card part 11
  380. ----- text -----
  381. Send $15.00 for the heavily commented LightSpeed C source code for the DragRect XFCN, and other XFCN‚Äôs and XCMD‚Äôs to:
  382.  
  383.       Richard P. Davis
  384.       260 Sheridan St. #100 
  385.       Palo Alto, Ca. 94306
  386.  
  387. The source files will be provided on an 800K diskette unless otherwise requested.